//
// Created by glt on 2025/3/16.
//


#include <vector>
#include <unordered_map>

#include "Person.h"


void method1(Person p){
    std::cout<<"method1 address::"<<&p<<std::endl;
    std::cout<< p.get_name()<<std::endl;
}

void method2(Person& p){
    std::cout<<"method2 address::"<<&p<<std::endl;
    p.name= "method2";
}

void method3(Person* p){
    std::cout<<"method3 address::"<<p<<std::endl;
    p = new Person("innner");
}

void method4(Person*& p){
    std::cout<<"before method4 address::"<<p<<std::endl;
    p = new Person("innner");
    std::cout<<"after method4 address::"<<p<<std::endl;
}

int main(){
//    Person p1("zhangsan");
//    std::cout<<"p1 address::"<<&p1<<std::endl;
//    //p1.sayHello();
//    method1(p1);
//    method2(p1);
//    method3(&p1);
////    method4(reinterpret_cast<Person *&>(p1));
////    std::cout<<"p1 name::"<<p1.name<< " address"<<&p1<<std::endl;
//    Person p2(p1);
//    p2.name="new p2";
//    std::cout<<"change name"<<std::endl;
//    Person p3 = p2;
//    p3.name="new p3";
    std::vector<Person> myvector;
    myvector.size();
//    std::cout<<"before init vector"<<std::endl;
//    myvector.push_back(p3);
//    std::cout<<"after init vector"<<std::endl;
//
//    Person p4 = p3;
//    p4.name="new p4";
//    std::unordered_map<std::string ,Person> my_map;
//    std::cout<<"init map"<<std::endl;
//    my_map["p1"]=p4;


    auto* p2 = new Person("lisi");
    std::cout<<"p2 address::"<<p2<<std::endl;
    method1(*p2);
    method2(*p2);
    std::cout<< "after method2 p2 name:"<< p2->get_name()<<std::endl;
    method3(p2);
    std::cout<< "after method3 p2 name:"<< p2->get_name()<<std::endl;
    method4(p2);
    std::cout<< "after method4 p2 name:"<< p2->get_name() << " address:"<< p2<<std::endl;
}